// 承保公司icon配置
import {creatEnum, deepCopy} from '@/utils/tools'

import imgConf from '@/img_path.json'

// 构建映射关系
function buildMap(conf){
    let name:string[] = [];
    let path:string[] = [];
    
    conf.forEach(item =>{
        name.push(item.name)
        path.push(item.path)       

    })

    return{
        name: creatEnum(name),
        path: creatEnum(path)
    }
}


let conf = imgConf.companyIcon;
let map = buildMap(conf);

// 获取icon地址
function getCmpIcon(name:string){

    let pathSign = map.name[name]
    return pathSign === undefined ? map.path[map.name['默认']] :  map.path[pathSign]
}

// 获取列表
function getCmpList(){
    return deepCopy(conf);
}


export {
    getCmpIcon,
    getCmpList
}
